package com.ease.framework.gef4g {
   import com.ease.framework.gef.Editor;
   import com.ease.framework.gef4g.actions.ZoomSlider;
   import com.ease.framework.layers.ZoomPan;
   import com.ease.framework.workbench.viewer.IViewer;

   import mx.containers.Canvas;
   import mx.containers.HDividedBox;
   import mx.core.Container;

   public class GraphicalEditor extends Editor implements IGraphicalEditor {
      protected var zoomPan:ZoomPan;

      public function GraphicalEditor() {
         super();
      }

      override public function createPartControl(parent:Container = null):Container {
         var hdbox:HDividedBox = new HDividedBox();
         hdbox.percentHeight = 100;
         hdbox.percentWidth = 100;

         var paletteControl:Container = getPaletteControl();
         if (paletteControl != null) {

            paletteControl.percentHeight = 100;
            hdbox.addChild(paletteControl);
         }
         var canvas:Canvas = new Canvas();
         canvas.percentHeight = 100;
         canvas.percentWidth = 100;

         var viewerControl:Container = getGraphicalViewer().getControl() as Container;
         viewerControl.percentHeight = 100;
         viewerControl.percentWidth = 100;
         canvas.addChild(viewerControl);

         zoomPan = new ZoomPan();

         var zoomSlider:ZoomSlider = new ZoomSlider();
         zoomSlider.x = 20;
         zoomSlider.y = 10;
         zoomSlider.styleName = "SliderBox";
         zoomPan.addChild(zoomSlider);

         zoomPan.x = viewerControl.x;
         zoomPan.percentHeight = 100;
         zoomPan.percentWidth = 100;
         canvas.addChild(zoomPan);

         hdbox.addChild(canvas);

         hiddenZoomSliderPan();

         return hdbox;
      }

      public function createGraphicalViewer():IGraphicalViewer {
         return null;
      }

      override public function createViewer():IViewer {
         return createGraphicalViewer();
      }

      public function getGraphicalViewer():IGraphicalViewer {
         return IGraphicalViewer(getViewer());
      }

      override public function clear():void {
         super.clear();
         this.getGraphicalViewer().getViewport().clear();
      }

      public function hiddenZoomSliderPan():void {
         zoomPan.enabled = false;
         zoomPan.visible = false;
      }

      public function showZoomSliderPan():void {
         zoomPan.enabled = true;
         zoomPan.visible = true;
      }
   }
}